<!DOCTYPE html>
<html lang="en">
<link rel="stylesheet" th:href="@{/assets/css/colorbox.css}" />
<head th:include="fragments/head::header" />
<body>
<div th:include="fragments/top::top"></div>
<div class="main-container" id="main-container">
    <div class="main-container-inner">
        <div th:include="fragments/left::left" class="sidebar" id="sidebar"></div>
        <div class="main-content">
            <div class="breadcrumbs" id="breadcrumbs">
                <ul class="breadcrumb">
                    <li><i class="icon-home home-icon"></i> <a href="#">首页</a></li>
                    <li><a href="#">系统管理</a></li>
                    <li><a href="#">编辑公告</a></li>
                </ul>
            </div>
            <div class="page-content">
                <h3 class="header smaller lighter blue">公告信息</h3>
                <div id="ulId" class=""></div>
                <br/>
                <form method="post" id="edit">
                    <div  class="tab-pane fade in active">
                        <div class="container">
                            <div class="form-horizontal">
                                <div class="form-group" style="height:29px">
                                    <label class="col-sm-3 control-label no-padding-right blue"> 开始日期：</label>
                                    <input class="Wdate col-sm-2" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"
                                           id="startTime" name="startTime" th:value="${news.startTime!=null}? ${#dates.format(news.startTime, 'yyyy-MM-dd HH:mm:ss')}"/>
                                    <label class="col-sm-3 control-label no-padding-right blue"> 结束日期：</label>
                                    <input class="Wdate col-sm-2" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"
                                           id="endTime" name="endTime" th:value="${news.endTime!=null}? ${#dates.format(news.endTime, 'yyyy-MM-dd HH:mm:ss')}"/>
                                </div>
                                <div flag="div_doHide" class="form-group" style="height:29px">
                                    <label class="col-sm-3 control-label no-padding-right blue"> 是否启用：</label>
                                    <select class="col-sm-3 form-control input-sm" name="enableStatus" style="width:190px;height:25px;">
                                        <option value="" selected="selected">请选择</option>
                                        <option value="1" th:selected="${news.enableStatus!=null}? ${news.enableStatus==1}">启用</option>
                                        <option value="0" th:selected="${news.enableStatus!=null}? ${news.enableStatus==0}">禁用</option>
                                    </select>
                                </div>
                                <div class="form-group" style="height:29px">
                                    <label class="col-sm-3 control-label no-padding-right no-padding-left blue" for="content"> 回访内容：</label>
                                    <textarea name="content" style="width:600px;height:180px;" verticalScrollPolicy="on" horizontalScrollPolicy="on" th:text="${news!=null}? ${news.content}"/>
                                    <!--ueditor-->
                                   <!-- <div class="table-responsive col-sm-9">
                                        &lt;!&ndash; 加载编辑器的容器 &ndash;&gt;
                                        <script id="content" name="content" type="text/plain"></script>
                                    </div>-->
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-primary" id="submits">保存</button>
                    </div>
                    <div id="alert" class="alert alert-success" style="display: none;" role="alert">
                        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                        <span id="alertText"></span>
                    </div>
                </form>
                <br/><br/><br/><br/><br/><br/><br/><br/>
            </div>
        </div>
        <div th:include="fragments/bottom::bottom"></div>
    </div>
    <a href="#" id="btn-scroll-up"
       class="btn-scroll-up btn btn-sm btn-inverse"> <i
            class="icon-double-angle-up icon-only bigger-110"></i>
    </a>
</div>
<!-- Modal备注 -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">

        </div>
    </div>
</div>
<!-- Modal备注 -->
<!--<div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body">
                <h2 style="color: green" id="result">审核通过</h2>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                </button>
            </div>
        </div>
    </div>
</div>-->
<div th:include="fragments/js::js"></div>
<!-- page specific plugin scripts -->
<script th:src="@{/assets/js/jquery.dataTables.min.js}"></script>
<script th:src="@{/assets/js/jquery.dataTables.bootstrap.js}"></script>
<script th:src="@{/assets/js/temp.js}" charset="UTF-8"></script>
<!--图片查看器-->
<script th:src="@{/assets/js/jquery.colorbox-min.js}"></script>
<script th:src="@{/layer/layer.js}"></script>
<script th:src="@{/My97DatePicker/WdatePicker.js}"></script>
<!--ueditor-->
<script type="text/javascript" charset="utf-8" th:src="@{/UEditor/ueditor.config.js}"></script>
<script type="text/javascript" charset="utf-8" th:src="@{/UEditor/ueditor.all.min.js}"></script>
<script type="text/javascript" charset="utf-8" th:src="@{/UEditor/lang/zh-cn/zh-cn.js}"></script>
<script type="text/javascript">
    var ueEditor;
    $(function () {
        if ($("#span_visitType").text() == "文案回访") {
            // 文案回访隐藏部分内容
            $("div[flag='div_doHide']").hide()
        }
        //加载文本编辑器
        ueEditor = UE.getEditor('content', {
            toolbars: [
                [//'anchor', //锚点
                    //'undo', //撤销
                    //'redo', //重做
                    'bold', //加粗
                    'indent', //首行缩进
                    //'snapscreen', //截图
                    'italic', //斜体
                    'underline', //下划线
                    'strikethrough', //删除线
                    'subscript', //下标
                    'fontborder', //字符边框
                    'superscript', //上标
                    'formatmatch', //格式刷
                    'source', //源代码
                    //'blockquote', //引用
                    'pasteplain', //纯文本粘贴模式
                    //'selectall', //全选
                    //'print', //打印
                    'preview', //预览
                    'horizontal', //分隔线
                    //'removeformat', //清除格式
                    'time', //时间
                    'date', //日期
                    //'unlink', //取消链接
                    'insertrow', //前插入行
                    'insertcol', //前插入列
                    //'mergeright', //右合并单元格
                    //'mergedown', //下合并单元格
                    'deleterow', //删除行
                    'deletecol', //删除列
                    //'splittorows', //拆分成行
                    //'splittocols', //拆分成列
                    //'splittocells', //完全拆分单元格
                    //'deletecaption', //删除表格标题
                    //'inserttitle', //插入标题
                    //'mergecells', //合并多个单元格
                    //'deletetable', //删除表格
                    'cleardoc', //清空文档
                    //'insertparagraphbeforetable', //"表格前插入行"
                    //'insertcode', //代码语言
                    'fontfamily', //字体
                    'fontsize', //字号
                    'paragraph', //段落格式
                    'simpleupload', //单图上传
                    //'insertimage', //多图上传
                    //'edittable', //表格属性
                    //'edittd', //单元格属性
                    'link', //超链接
                    'emotion', //表情
                    'spechars', //特殊字符
                    'searchreplace', //查询替换
                    //'map', //Baidu地图
                    //'gmap', //Google地图
                    //'insertvideo', //视频
                    //'help', //帮助
                    'justifyleft', //居左对齐
                    'justifyright', //居右对齐
                    'justifycenter', //居中对齐
                    'justifyjustify', //两端对齐
                    'forecolor', //字体颜色
                    'backcolor', //背景色
                    //'insertorderedlist', //有序列表
                    //'insertunorderedlist', //无序列表
                    //'fullscreen', //全屏
                    //'directionalityltr', //从左向右输入
                    //'directionalityrtl', //从右向左输入
                    'rowspacingtop', //段前距
                    'rowspacingbottom', //段后距
                    //'pagebreak', //分页
                    //'insertframe', //插入Iframe
                    'imagenone', //默认
                    'imageleft', //左浮动
                    'imageright', //右浮动
                    //'attachment', //附件
                    'imagecenter', //居中
                    'wordimage', //图片转存
                    'lineheight', //行间距
                    //'edittip ', //编辑提示
                    //'customstyle', //自定义标题
                    'autotypeset', //自动排版
                    //'webapp', //百度应用
                    'touppercase', //字母大写
                    'tolowercase', //字母小写
                    //'background', //背景
                    //'template', //模板
                    //'scrawl', //涂鸦
                    //'music', //音乐
                    //'inserttable', //插入表格
                    //'drafts', // 从草稿箱加载
                    //'charts' // 图表
                ]
            ],
            initialFrameHeight: 500,
            'enterTag': 'p'
        });
        ueEditor.ready(function() {
            ueEditor.setContent($("#span_content").text());
        });
        $("#submits").click(function () {
            $.ajax({
                url: "/news/save",
                type: "post",
                data: $("#edit").serialize(),
                success: function (data) {
                    if (data) {
                        $(".alert-success").text("操作成功").show();
                        $('#alert').attr('class','alert alert-success').show();
                        setTimeout(function () {
                            $('#alert').hide();
                            $("#myModal").modal("hide");
                            //window.location.href="/visit";
                        }, 2000);
                    } else {
                        $('#alertText').text('操作失败');
                        $('#alert').attr('class','alert alert-danger').show();
                        setTimeout("$('#alert').hide()", 2000);
                        $("#myModal").modal("hide");
                    }
                }
            });
        })

        //监听modal关闭事件，清除整个页面的缓存数据
        $("#myModal").on("hidden.bs.modal", function () {
            $(this).removeData("bs.modal");
        });
    });
</script>
</body>
</html>
